﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CopsBanditsUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import Classes.*;
    import Classes.util.*;
    import Modules.workers.*;
    import Modules.bandits.*;

    public class BanditCapturedDialog extends GenericDialog {

        protected var m_bandit:BanditData;
        protected var m_cop:Player;
        protected var m_iconLoader:Loader;
        protected var m_rewardLoader:Loader;
        protected var m_comTabObject:Object;
        protected var m_numAssetLoads:int = 3;
        protected var m_imagesLoaded:int = 0;
        protected var m_itemOnly:Boolean;

        public function BanditCapturedDialog(_arg1:int, _arg2:CopData, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Function=null, _arg6:Boolean=true, _arg7:Function=null){
            var _local8:Object = {id:_arg1};
            this.m_bandit = new BanditData(_local8);
            var _local9 = "-1";
            if (_arg2){
                _local9 = _arg2.getZID();
            };
            if (_local9.indexOf("i") >= 0){
                _local9 = _local9.substr((_local9.indexOf("i") + 1));
            };
            if (_local9.indexOf("-") >= 0){
                _local9 = "-1";
            };
            this.m_cop = Global.player.findFriendById(_local9);
            this.m_itemOnly = _arg4;
            var _local10:String = ZLoc.t("Dialogs", "CapturedBandit_buttonText");
            var _local11 = "CapturedBandit";
            var _local12 = "";
            var _local13:int = BanditManager.getNumBanditsUntilUpgrade();
            var _local14:String = (this.m_cop) ? this.m_cop.firstName : "";
            if ((((_local13 > 0)) && (!(_arg4)))){
                _local12 = ZLoc.t("Dialogs", "CapturedBandit_message", {
                    friendName:_local14,
                    banditName:this.m_bandit.name,
                    numBandits:_local13
                });
            } else {
                if ((((_local13 == 0)) && (!(_arg4)))){
                    _local12 = ZLoc.t("Dialogs", "CapturedBandit_message_readyForUpgrade", {
                        friendName:_local14,
                        banditName:this.m_bandit.name
                    });
                } else {
                    if ((((_local13 == -1)) && (!(_arg4)))){
                        _local12 = ZLoc.t("Dialogs", "CapturedBandit_message_noMoreUpgrades", {
                            friendName:_local14,
                            banditName:this.m_bandit.name
                        });
                    } else {
                        if (_arg4){
                            _local12 = ZLoc.t("Dialogs", "CapturedBandit_item_message", {
                                friendName:_local14,
                                banditName:this.m_bandit.name
                            });
                        };
                    };
                };
            };
            if (((_arg3) && (!(_arg4)))){
                _local12 = (_local12 + (" " + ZLoc.t("Dialogs", "CapturedBandit_item_append_message")));
            };
            var _local15:int = GenericDialogView.TYPE_CUSTOM_OK;
            var _local16:Function = _arg5;
            if (_arg4){
                _local15 = GenericDialogView.TYPE_OK;
                _local16 = null;
            };
            super(_local12, _local11, _local15, _local16, _local11, "", _arg6, 0, "", _arg7, _local10, true);
        }
        override protected function loadAssets():void{
            if (this.m_bandit.rewardItems.length > 0){
                this.m_numAssetLoads++;
            };
            Global.delayedAssets.get(DelayedAssetLoader.GENERIC_DIALOG_ASSETS, makeAssets);
            Global.delayedAssets.get(DelayedAssetLoader.TABBED_ASSETS, this.makeTabAssets);
            if (this.m_bandit.portraitUrl){
                this.m_iconLoader = LoadingManager.load(Global.getAssetURL(this.m_bandit.caughtUrl), this.onAssetsLoaded, LoadingManager.PRIORITY_HIGH);
            };
            if (this.m_bandit.rewardItems.length > 0){
                this.m_rewardLoader = LoadingManager.load(Global.gameSettings.getImageByName(this.m_bandit.rewardItems[0], "icon"), this.onAssetsLoaded, LoadingManager.PRIORITY_HIGH);
            };
        }
        protected function makeTabAssets(_arg1:DisplayObject, _arg2:String):void{
            this.m_comTabObject = _arg1;
            this.onAssetsLoaded();
        }
        override protected function onAssetsLoaded(_arg1:Event=null):void{
            this.m_imagesLoaded++;
            if (this.m_imagesLoaded < this.m_numAssetLoads){
                return;
            };
            super.onAssetsLoaded(_arg1);
        }
        override protected function createAssetDict():Dictionary{
            var _local1:Dictionary = new Dictionary();
            _local1["dialog_bg"] = (new m_comObject.dialog_bg() as DisplayObject);
            m_assetBG = _local1["dialog_bg"];
            if (this.m_iconLoader){
                _local1["banditIcon"] = this.m_iconLoader.content;
            };
            _local1["rewardCard_unlocked"] = this.m_comTabObject.police_rewardCard_unlocked;
            _local1["police_slot_unfilled"] = this.m_comTabObject.police_slot_unfilled;
            if (this.m_rewardLoader){
                _local1["itemReward"] = this.m_rewardLoader.content;
            };
            return (_local1);
        }
        override protected function createDialogView(_arg1:Dictionary):GenericDialogView{
            var _local2:GenericDialogView = new BanditCapturedDialogView(_arg1, this.m_bandit, this.m_cop, this.m_itemOnly, m_message, m_dialogTitle, m_callback, m_SkipCallback, m_customOk);
            return (_local2);
        }

    }
}//package Display.CopsBanditsUI 
